package com.wm.memento;

/**
 * @ClassName: Originator
 * @Description: 发起人
 * @Author: WM
 * @Date: 2023/5/16 9:30
 */
public class Originator {
    // 记录当前对象的内部状态
    private String value;

    public Originator(String value) {
        this.value = value;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    // 创建备忘录
    public Memento createMemento() {
        return new Memento(this.value);
    }

    // 恢复备忘录的数据
    public void restoreMemento(Memento memento) {
        this.value = memento.getValue();
    }
}
